package com.itheima.bos.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itheima.bos.dao.CourierRepository;
import com.itheima.bos.domain.base.Courier;
import com.itheima.bos.service.CourierService;

@Service
@Transactional
public class CourierServiceImpl implements CourierService {
	
	@Autowired
	private CourierRepository courierRepository;
	
	@Override
	public void courier_save(Courier model) {
		courierRepository.save(model);
	}

	@Override
	public Page<Courier> courier_pageQuery(Specification<Courier> spec,Pageable pageable) {
		Page<Courier> page = courierRepository.findAll(spec, pageable);
		return page;
	}

	@Override
	public void delete(String[] ids) {
		for (String id : ids) {
			courierRepository.updateDelTag(Integer.parseInt(id));
		}
	}

	@Override
	public List<Courier> findNoAssociation() {
		List<Courier> list = courierRepository.findByFixedAreasIsNull();
		return list;
	}

}
